var z = Object.defineProperty, P = Object.defineProperties;
var E = Object.getOwnPropertyDescriptors;
var g = Object.getOwnPropertySymbols;
var R = Object.prototype.hasOwnProperty, W = Object.prototype.propertyIsEnumerable;
var m = (e, n, l) => n in e ? z(e, n, { enumerable: !0, configurable: !0, writable: !0, value: l }) : e[n] = l, y = (e, n) => {
  for (var l in n || (n = {}))
    R.call(n, l) && m(e, l, n[l]);
  if (g)
    for (var l of g(n))
      W.call(n, l) && m(e, l, n[l]);
  return e;
}, p = (e, n) => P(e, E(n));
import { ref as d, reactive as j, computed as i, watch as O, onMounted as G } from "vue";
import { c as H } from "../component-87e22bdd.mjs";
import { c as J } from "../props-c0e5b20d.mjs";
/*!
* Vin UI 移动端 Vue3 组件库 v0.2.9 Fri Jun 02 2023 21:01:02 GMT+0800 (中国标准时间)
* (c) 2023 @vingogo.
* Released under the MIT License.
*/
function S(e, n, l) {
  const r = e.indexOf(n);
  return r === -1 ? e : n === "-" && r !== 0 ? e.slice(0, r) : e.slice(0, r + 1) + e.slice(r).replace(l, "");
}
function b(e, n = !0, l = !0) {
  n ? e = S(e, ".", /\./g) : e = e.split(".")[0], l ? e = S(e, "-", /-/g) : e = e.replace(/-/, "");
  const r = n ? /[^-0-9.]/g : /[^-0-9]/g;
  return e.replace(r, "");
}
const K = p(y({}, J), {
  ref: {
    type: String,
    default: ""
  },
  modelValue: {
    type: String,
    default: ""
  },
  type: {
    type: String,
    default: "text"
  },
  placeholder: {
    type: String,
    default: ""
  },
  label: {
    type: String,
    default: ""
  },
  labelClass: {
    type: String,
    default: ""
  },
  labelWidth: {
    type: [String, Number],
    default: "80"
  },
  labelAlign: {
    type: String,
    default: "left"
  },
  inputAlign: {
    type: String,
    default: "left"
  },
  colon: {
    type: Boolean,
    default: !1
  },
  required: {
    type: Boolean,
    default: !1
  },
  border: {
    type: Boolean,
    default: !0
  },
  disabled: {
    type: Boolean,
    default: !1
  },
  readonly: {
    type: Boolean,
    default: !1
  },
  autofocus: {
    type: Boolean,
    default: !1
  },
  maxLength: {
    type: [String, Number],
    default: ""
  },
  clearable: {
    type: Boolean,
    default: !1
  },
  clearIcon: {
    type: String,
    default: "mask-close"
  },
  clearSize: {
    type: [String, Number],
    default: "14"
  },
  leftIconSize: {
    type: [String, Number],
    default: ""
  },
  leftIcon: {
    type: String,
    default: ""
  },
  rightIcon: {
    type: String,
    default: ""
  },
  rightIconSize: {
    type: [String, Number],
    default: ""
  },
  showWordLimit: {
    type: Boolean,
    default: !1
  },
  center: {
    type: Boolean,
    default: !1
  },
  rules: {
    type: Array,
    default: []
  },
  rows: {
    type: [String, Number],
    default: null
  },
  error: {
    type: Boolean,
    default: !1
  },
  errorMessage: {
    type: String,
    default: ""
  },
  errorMessageAlign: {
    type: String,
    default: ""
  },
  formatter: {
    type: Function,
    default: null
  },
  formatTrigger: {
    type: String,
    default: "onChange"
  },
  adjustPosition: {
    type: Boolean,
    default: !0
  }
}), { componentName: Q, create: U, useVinContext: X } = H("input"), v = U({
  props: K,
  emits: [
    "update:modelValue",
    "change",
    "blur",
    "focus",
    "clear",
    "click-input",
    "click-left-icon",
    "click-right-icon",
    "confirm"
  ],
  setup(e, { emit: n, slots: l }) {
    const { getMainClass: r, getMainStyle: h } = X(e), u = d(!1), x = d(), s = d(), c = () => {
      var t;
      return String((t = e.modelValue) != null ? t : "");
    }, f = j({
      focused: !1,
      validateFailed: !1,
      // 校验失败
      validateMessage: ""
      // 校验信息
    }), B = i(() => {
      const t = Q;
      return r({
        center: e.center,
        [`${t}-disabled`]: e.disabled,
        [`${t}-required`]: e.required,
        [`${t}-error`]: e.error,
        [`${t}-border`]: e.border
      });
    }), C = i(h), V = i(() => ({
      textAlign: e.inputAlign
    })), N = i(() => ({
      textAlign: e.inputAlign,
      height: `${Number(e.rows) * 24}px`
    })), k = (t) => t === "number" ? "text" : t === "digit" ? "tel" : t;
    i(() => s.value && l.input ? s.value() : e.modelValue);
    const o = (t, a = "onChange") => {
      e.type === "digit" && (t = b(t, !1, !1)), e.type === "number" && (t = b(t, !0, !0)), e.formatter && a === e.formatTrigger && (t = e.formatter(t)), t !== e.modelValue && (n("update:modelValue", t), n("change", t));
    }, I = (t) => {
      const { value: a } = t.detail;
      o(a);
    }, A = (t) => {
      const { value: a } = t.detail;
      n("confirm", a, t);
    }, M = (t) => {
      const { value: a } = t.detail;
      u.value = !0, n("focus", a, t);
    }, L = (t) => {
      setTimeout(() => {
        u.value = !1;
      }, 200);
      let { value: a } = t.detail;
      e.maxLength && a.length > Number(e.maxLength) && (a = a.slice(0, Number(e.maxLength))), o(c(), "onBlur"), n("blur", a, t);
    }, T = (t) => {
      n("update:modelValue", "", t), n("change", "", t), n("clear", "", t);
    }, F = () => {
      f.validateFailed && (f.validateFailed = !1, f.validateMessage = "");
    }, $ = (t) => {
      n("click-input", t);
    }, q = (t) => n("click-left-icon", t), w = (t) => n("click-right-icon", t);
    return O(
      () => e.modelValue,
      () => {
        o(c()), F();
      }
    ), G(() => {
      o(c(), e.formatTrigger);
    }), {
      inputRef: x,
      active: u,
      mainClass: B,
      styles: V,
      mainStyle: C,
      stylesTextarea: N,
      inputType: k,
      onInput: I,
      onFocus: M,
      onBlur: L,
      onConfirm: A,
      clear: T,
      onClickInput: $,
      onClickLeftIcon: q,
      onClickRightIcon: w
    };
  }
});
export {
  v as default
};
